package com.ftg.learn.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 布衣
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R<T> {

    private Integer code;

    private String msg;

    private T data;

    public static <T> R<T> ok(T data) {
        return new R<>(200, "success", data);
    }

    public static <T> R<T> fail() {
        return new R<>(500, "failure", null);
    }

    public static <T> R<T> fail(String msg) {
        return new R<>(500, msg, null);
    }
}
